"use strict";
define(["echarts","commonUI","getTime","laydate", "template","global","select2", "datatables","nav"], function (
    echarts, commonUI, getTime,laydate,template,global
) {
    var project = null;
    var user = null;
    var baseYear1 = 2021;
    var baseYear2 = 2021;
    var baseYear3 = 2021;
    var chart11,chart12,chart13,chart14,chart21,chart22,chart23,chart31,chart32,chart41,chart42;
    var app = {
        init: function () {
            if(!global.existCurrProject()){
                alert("请先选择项目")
                return;
            }
            project = global.getCurrProject();
            user = global.getLoginUser();
            this.initText()
            this.initTab1();
            // this.initTab2();
            // this.initTab3();
            this.eventBind();
            // getTime.resize();
            getTime.getNowDate();
            getTime.getTimeInfo();
        },
        /**
        * 渲染文字内容
        */
        initText: function() {
            //用户名显示
            $(".name").text(user.userName)
        },
        initTab1: function () {
            app.initChart11();
            app.initChart12();
            app.initChart13();
            app.initChart14();
            app.initSelect();
            app.initChart21();
            app.initChart22();
            app.initChart23();
        },
        initTab2: function () {
            app.initChart31();
            app.initChart32();
        },
        initTab3: function () {
            app.initChart41();
            app.initChart42();
        },
        initChart11: function () {
            if (chart11) {
                chart11.dispose();
            }
            var type = $("#timeType11 li.active").attr("type");
            var timeLength = 0;
            if(type==0){
                timeLength=10;
            }else if(type==1){
                timeLength=10
            }else if(type==2){
                timeLength=10
            }
            global.get("/web/analysis/energy_efficiency/machine_group_efficiency/"+project.id+"?timeMode="+type+"&timeLength="+timeLength,response=>{
                if(response.success){
                    var xArr = []
                    var legend_data = [];
                    var series = [];
                    var dates = response.data.dates;
                    response.data.machineGroup.forEach(item=>{
                        legend_data.push(item.name);
                        var serie = {
                            name:item.name,
                            smooth: true,
                            type: "line",
                            data:item.efficiency
                        }
                        series.push(serie)
                    })

                    for(var i=0;i<dates.length;i++){
                        if(type==0){
                            xArr.push(dates[i].substring(11,13)+"时");
                        }else if(type==1){
                            xArr.push(dates[i].substring(8,10)+"日");
                        }else if(type==2){
                            xArr.push(dates[i].substring(5,7)+"月");
                        }
                    }
                    var option = {
                        tooltip: {
                            trigger: "axis"
                        },
                        legend: {
                            data: legend_data,
                            right: 24,
                            top: 0,
                            selectedMode: false,
                            textStyle: {
                                color: "#94d3ff"
                            }
                        },
                        grid: {
                            left: 24,
                            right: 24,
                            bottom: 0,
                            top: 36,
                            containLabel: true
                        },
                        xAxis: [
                            {
                                type: "category",
                                boundaryGap: false,
                                axisTick: {
                                    show: false
                                },
                                axisLine: {
                                    lineStyle: {
                                        color: "#ffffff"
                                    }
                                },
                                axisLabel: {
                                    color: "#94d3ff"
                                },
                                data: xArr
                            }
                        ],
                        yAxis: [
                            {
                                name: "COP",
                                type: "value",
                                splitNumber: 2,
                                nameTextStyle: {
                                    color: "#94d3ff"
                                },
                                axisTick: {
                                    show: false
                                },
                                axisLine: {
                                    show: false
                                },
                                axisLabel: {
                                    color: "#94d3ff"
                                },
                                splitLine: {
                                    lineStyle: {
                                        type: "dashed",
                                        color: "#94d3ff",
                                        opacity: 0.5
                                    }
                                }
                            }
                        ],
                        series: series,
                        color: ["#b9d0ff", "#fddd99"]
                    };
                    chart11 = echarts.init(document.getElementById("chart11"));
                    chart11.setOption(option);
                }else{
                    alert(response.message)
                }
            });
            
        },
        initChart12: function () {
            if (chart12) {
                chart12.dispose();
            }
            var type = $("#timeType12 li.active").attr("type");
            var timeLength = 0;
            if(type==0){
                timeLength=10;
            }else if(type==1){
                timeLength=10
            }else if(type==2){
                timeLength=10
            }
            global.get("/web/analysis/energy_efficiency/system_efficiency/"+project.id+"?timeMode="+type+"&timeLength="+timeLength,response=>{
                if(response.success){
                    var xArr = []
                    var legend_data = ["制冷系统","供暖系统"];
                    var dates = response.data.dates;
                    
                    for(var i=0;i<dates.length;i++){
                        if(type==0){
                            xArr.push(dates[i].substring(11,13)+"时");
                        }else if(type==1){
                            xArr.push(dates[i].substring(8,10)+"日");
                        }else if(type==2){
                            xArr.push(dates[i].substring(5,7)+"月");
                        }
                    }
                    var option = {
                        tooltip: {
                            trigger: "axis"
                        },
                        legend: {
                            data: legend_data,
                            right: 24,
                            top: 0,
                            selectedMode: false,
                            textStyle: {
                                color: "#94d3ff"
                            }
                        },
                        grid: {
                            left: 24,
                            right: 24,
                            bottom: 0,
                            top: 36,
                            containLabel: true
                        },
                        xAxis: [
                            {
                                type: "category",
                                boundaryGap: false,
                                axisTick: {
                                    show: false
                                },
                                axisLine: {
                                    lineStyle: {
                                        color: "#ffffff"
                                    }
                                },
                                axisLabel: {
                                    color: "#94d3ff"
                                },
                                data: xArr
                            }
                        ],
                        yAxis: [
                            {
                                name: "COP",
                                type: "value",
                                splitNumber: 2,
                                nameTextStyle: {
                                    color: "#94d3ff"
                                },
                                axisTick: {
                                    show: false
                                },
                                axisLine: {
                                    show: false
                                },
                                axisLabel: {
                                    color: "#94d3ff"
                                },
                                splitLine: {
                                    lineStyle: {
                                        type: "dashed",
                                        color: "#94d3ff",
                                        opacity: 0.5
                                    }
                                }
                            }
                        ],
                        series: [
                            {
                                name: "制冷系统",
                                smooth: true,
                                type: "line",
                                data: response.data.coolingEfficiency
                            },
                            {
                                name: "供暖系统",
                                smooth: true,
                                type: "line",
                                data: response.data.heatingEfficiency
                            }
                        ],
                        color: ["#b9d0ff", "#fddd99"]
                    };
                    chart12 = echarts.init(document.getElementById("chart12"));
                    chart12.setOption(option);
                }else{
                    alert(response.message)
                }
            });
        },
        initChart13: function () {
            if (chart13) {
                chart13.dispose();
            }
            global.get("/web/analysis/energy_efficiency/powercost/"+project.id,response=>{
                if(response.success){
                    var data = [];
                    var types = response.data.types;
                    var powercosts = response.data.powercosts;
                    for(var i=0;i<types.length;i++){
                        var item = {};
                        item.value = powercosts[i]!=null?powercosts[i]:0;
                        item.name = types[i];
                        data.push(item);
                    }
                    
                    var option = {
                        tooltip : {
                            show:false,
                            trigger: 'item',
                            formatter: "{a} <br/>{b} : {c} ({d}%)"
                        },
                        series : [
                            {
                                name: '访问来源',
                                type: 'pie',
                                radius : '60%',
                                center: ['50%', '50%'],
                                data:data,
                                itemStyle: {
                                    emphasis: {
                                        shadowBlur: 10,
                                        shadowOffsetX: 0,
                                        shadowColor: 'rgba(0, 0, 0, 0.5)'
                                    }
                                },
                                label: {
                                    normal: {
                                        formatter: '{b}'+'\n'+'占比: {d}%',
                                        color: "#94d3ff",
                                        fontSize: 14,
                                        lineHeight: 24
                                    }
                                },
                                labelLine: {
                                    normal: {
                                        length2: 50,
                                        lineStyle: {
                                            type: "dashed"
                                        }
                                    }
                                }
                            }
                        ],
                        color: ["#af3b38", "#b76142", "#b4aa8d", "#a4aebb", "#7699e3", "#695e96"] 
                    };           
                    chart13 = echarts.init(document.getElementById("chart13"));
                    chart13.setOption(option);
                }else{
                    alert(response.message)
                }
            })
        },
        initChart14: function () {
            if (chart14) {
                chart14.dispose();
            }
            var mode = $("#timeType4 li.active").attr("type");
            var timeLength = 10;
            global.get("/web/analysis/energy_efficiency/system_powercost_std/"+project.id+"?timeLength="+timeLength + "&mode=0" + "&timeMode=1",response=>{
                if(response.success){
                    var xArr = []
                    var legend_data = ["制冷系统","供暖系统"];
                    var dates = response.data.dates;
                    for(var i=0;i<dates.length;i++){
                        xArr.push(dates[i].substring(8,10)+"日");
                    }
                    var option = {
                        tooltip: {
                            trigger: "axis"
                        },
                        legend: {
                            data: legend_data[mode],
                            right: 24,
                            top: 0,
                            selectedMode: false,
                            textStyle: {
                                color: "#94d3ff"
                            }
                        },
                        grid: {
                            left: 24,
                            right: 24,
                            bottom: 0,
                            top: 36,
                            containLabel: true
                        },
                        xAxis: [
                            {
                                type: "category",
                                boundaryGap: false,
                                axisTick: {
                                    show: false
                                },
                                axisLine: {
                                    lineStyle: {
                                        color: "#ffffff"
                                    }
                                },
                                axisLabel: {
                                    color: "#94d3ff"
                                },
                                data: xArr
                            }
                        ],
                        yAxis: [
                            {
                                name: "KWH/M2",
                                type: "value",
                                splitNumber: 2,
                                nameTextStyle: {
                                    color: "#94d3ff"
                                },
                                axisTick: {
                                    show: false
                                },
                                axisLine: {
                                    show: false
                                },
                                axisLabel: {
                                    color: "#94d3ff"
                                },
                                splitLine: {
                                    lineStyle: {
                                        type: "dashed",
                                        color: "#94d3ff",
                                        opacity: 0.5
                                    }
                                }
                            }
                        ],
                        series: [
                            {
                                name: "系统能效指标",
                                type: "line",
                                smooth: true,
                                areaStyle: {
                                    normal: {
                                        // opacity: 0.2
                                        color: {
                                            type: 'linear',
                                            x: 0,
                                            y: 0,
                                            x2: 0,
                                            y2: 1,
                                            colorStops: [{
                                                offset: 0, color: 'rgba(0, 246, 255, 0.5)' // 0% 处的颜色
                                            }, {
                                                offset: 1, color: 'rgba(0, 246, 255, 0)' // 100% 处的颜色
                                            }],
                                            globalCoord: false // 缺省为 false
                                        }
                                    }
                                },
                                data: response.data.systemPowercostStd
                            }
                        ],
                        color: ["#b9d0ff", "#fddd99"]
                    };
                    chart14 = echarts.init(document.getElementById("chart14"));
                    chart14.setOption(option);
                }else{
                    alert(response.message)
                }
            });
        },
        initChart21: function () {
            if (chart21) {
                chart21.dispose();
            }
            baseYear1 = $("#timeType21").val();
            global.get("/web/analysis/energy_efficiency/machine_group_efficiency/"+project.id+"?timeMode=3&baseYear="+baseYear1,response=>{
                if(response.success){
                    var xArr = []
                    var legend_data = [];
                    var series = [];
                    var dates = response.data.dates;
                    response.data.machineGroup.forEach(item=>{
                        legend_data.push(item.name);
                        var serie = {
                            name:item.name,
                            smooth: true,
                            type: "line",
                            data:item.efficiency
                        }
                        series.push(serie)
                    })

                    for(var i=0;i<dates.length;i++){
                        xArr.push(dates[i].substring(8,10)+"日");
                    }
                    var option = {
                        tooltip: {
                            trigger: "axis"
                        },
                        legend: {
                            data: legend_data,
                            top: 0,
                            selectedMode: false,
                            icon: "rect",
                            itemWidth: 16,
                            itemHeight: 16,
                            textStyle: {
                                color: "#94d3ff"
                            }
                        },
                        grid: {
                            left: 24,
                            right: 48,
                            bottom: 24,
                            top: 36,
                            containLabel: true
                        },
                        dataZoom: [{
                            type: "slider",
                            height: 4,
                            bottom: 10,
                            borderColor: "transparent",
                            backgroundColor: "#e2e2e2",
                            handleIcon: "M10.7,11.9H9.3c-4.9,0.3-8.8,4.4-8.8,9.4c0,5,3.9,9.1,8.8,9.4h1.3c4.9-0.3,8.8-4.4,8.8-9.4C19.5,16.3,15.6,12.2,10.7,11.9z M13.3,24.4H6.7v-1.2h6.6z M13.3,22H6.7v-1.2h6.6z M13.3,19.6H6.7v-1.2h6.6z", // jshint ignore:line
                            handleSize: 14,
                            handleStyle: {
                                shadowBlur: 3,
                                shadowOffsetX: 1,
                                shadowOffsetY: 1,
                                shadowColor: "#aaa"
                            },
                            textStyle: {
                                color: "#94d3ff"
                            }
                        }, {
                            type: "inside"
                        }],
                        xAxis: [
                            {
                                type: "category",
                                boundaryGap: false,
                                axisTick: {
                                    show: false
                                },
                                axisLine: {
                                    lineStyle: {
                                        color: "#ffffff"
                                    }
                                },
                                axisLabel: {
                                    color: "#94d3ff"
                                },
                                data: xArr
                            }
                        ],
                        yAxis: [
                            {
                                name: "COP",
                                type: "value",
                                splitNumber: 2,
                                nameTextStyle: {
                                    color: "#94d3ff"
                                },
                                axisTick: {
                                    show: false
                                },
                                axisLine: {
                                    show: false
                                },
                                axisLabel: {
                                    color: "#94d3ff"
                                },
                                splitLine: {
                                    lineStyle: {
                                        type: "dashed",
                                        color: "#94d3ff",
                                        opacity: 0.5
                                    }
                                }
                            }
                        ],
                        series: series,
                        color: ["#b9d0ff", "#fddd99"]
                    };
                    chart21 = echarts.init(document.getElementById("chart21"));
                    chart21.setOption(option);
                }else{
                    alert(response.message)
                }
            });
        },
        initChart22: function () {
            if (chart22) {
                chart22.dispose();
            }
            baseYear2 = $("#timeType22").val();
            global.get("/web/analysis/energy_efficiency/system_efficiency/"+project.id+"?timeMode=3&baseYear="+baseYear2,response=>{
                if(response.success){

                    var xArr = []
                    var legend_data = ["制冷系统","供暖系统"];
                    var dates = response.data.dates;
                    for(var i=0;i<dates.length;i++){
                        xArr.push(dates[i].substring(8,10)+"日");

                    }
                    var option = {
                        tooltip: {
                            trigger: "axis"
                        },
                        legend: {
                            data: legend_data,
                            left: 'center',
                            top: 0,
                            selectedMode: false,
                            icon: "rect",
                            itemWidth: 16,
                            itemHeight: 16,
                            textStyle: {
                                color: "#94d3ff"
                            }
                        },
                        grid: {
                            left: 24,
                            right: 48,
                            bottom: 24,
                            top: 36,
                            containLabel: true
                        },
                        dataZoom: [{
                            type: "slider",
                            height: 4,
                            bottom: 10,
                            borderColor: "transparent",
                            backgroundColor: "#e2e2e2",
                            handleIcon: "M10.7,11.9H9.3c-4.9,0.3-8.8,4.4-8.8,9.4c0,5,3.9,9.1,8.8,9.4h1.3c4.9-0.3,8.8-4.4,8.8-9.4C19.5,16.3,15.6,12.2,10.7,11.9z M13.3,24.4H6.7v-1.2h6.6z M13.3,22H6.7v-1.2h6.6z M13.3,19.6H6.7v-1.2h6.6z", // jshint ignore:line
                            handleSize: 14,
                            handleStyle: {
                                shadowBlur: 3,
                                shadowOffsetX: 1,
                                shadowOffsetY: 1,
                                shadowColor: "#aaa"
                            },
                            textStyle: {
                                color: "#94d3ff"
                            }
                        }, {
                            type: "inside"
                        }],
                        xAxis: [
                            {
                                type: "category",
                                boundaryGap: false,
                                axisTick: {
                                    show: false
                                },
                                axisLine: {
                                    lineStyle: {
                                        color: "#ffffff"
                                    }
                                },
                                axisLabel: {
                                    color: "#94d3ff"
                                },
                                data: xArr
                            }
                        ],
                        yAxis: [
                            {
                                name: "COP",
                                type: "value",
                                splitNumber: 2,
                                nameTextStyle: {
                                    color: "#94d3ff"
                                },
                                axisTick: {
                                    show: false
                                },
                                axisLine: {
                                    show: false
                                },
                                axisLabel: {
                                    color: "#94d3ff"
                                },
                                splitLine: {
                                    lineStyle: {
                                        type: "dashed",
                                        color: "#94d3ff",
                                        opacity: 0.5
                                    }
                                }
                            }
                        ],
                        series: [
                            {
                                name: "制冷系统",
                                smooth: true,
                                type: "line",
                                data: response.data.coolingEfficiency
                            },
                            {
                                name: "供暖系统",
                                smooth: true,
                                type: "line",
                                data: response.data.heatingEfficiency
                            }
                        ],
                        color: ["#b9d0ff", "#fddd99"]
                    };
                    chart22 = echarts.init(document.getElementById("chart22"));
                    chart22.setOption(option);
                }else{
                    alert(response.message)
                }
            });
        },
        initChart23: function () {
            if (chart23) {
                chart23.dispose();
            }
            baseYear3 = $("#timeType23").val();
            global.get("/web/analysis/energy_efficiency/system_powercost_std/"+project.id+"?timeMode=3&mode=0&baseYear="+baseYear3,response=>{
                if(response.success){

                    var xArr = []
                    var legend_data = ["制冷系统","供暖系统"];
                    var dates = response.data.dates;
                    for(var i=0;i<dates.length;i++){
                        xArr.push(dates[i].substring(8,10)+"日");

                    }
                    var option = {
                        tooltip: {
                            trigger: "axis"
                        },
                        legend: {
                            data: legend_data,
                            left: 'center',
                            top: 0,
                            selectedMode: false,
                            icon: "rect",
                            itemWidth: 16,
                            itemHeight: 16,
                            textStyle: {
                                color: "#94d3ff"
                            }
                        },
                        grid: {
                            left: 24,
                            right: 48,
                            bottom: 24,
                            top: 36,
                            containLabel: true
                        },
                        dataZoom: [{
                            type: "slider",
                            height: 4,
                            bottom: 10,
                            borderColor: "transparent",
                            backgroundColor: "#e2e2e2",
                            handleIcon: "M10.7,11.9H9.3c-4.9,0.3-8.8,4.4-8.8,9.4c0,5,3.9,9.1,8.8,9.4h1.3c4.9-0.3,8.8-4.4,8.8-9.4C19.5,16.3,15.6,12.2,10.7,11.9z M13.3,24.4H6.7v-1.2h6.6z M13.3,22H6.7v-1.2h6.6z M13.3,19.6H6.7v-1.2h6.6z", // jshint ignore:line
                            handleSize: 14,
                            handleStyle: {
                                shadowBlur: 3,
                                shadowOffsetX: 1,
                                shadowOffsetY: 1,
                                shadowColor: "#aaa"
                            },
                            textStyle: {
                                color: "#94d3ff"
                            }
                        }, {
                            type: "inside"
                        }],
                        xAxis: [
                            {
                                type: "category",
                                boundaryGap: false,
                                axisTick: {
                                    show: false
                                },
                                axisLine: {
                                    lineStyle: {
                                        color: "#ffffff"
                                    }
                                },
                                axisLabel: {
                                    color: "#94d3ff"
                                },
                                data: xArr
                            }
                        ],
                        yAxis: [
                            {
                                name: "KWH/M2",
                                type: "value",
                                splitNumber: 2,
                                nameTextStyle: {
                                    color: "#94d3ff"
                                },
                                axisTick: {
                                    show: false
                                },
                                axisLine: {
                                    show: false
                                },
                                axisLabel: {
                                    color: "#94d3ff"
                                },
                                splitLine: {
                                    lineStyle: {
                                        type: "dashed",
                                        color: "#94d3ff",
                                        opacity: 0.5
                                    }
                                }
                            }
                        ],
                        series: [
                            {
                                name: "制冷系统",
                                smooth: true,
                                type: "line",
                                data: response.data.systemPowercostStd
                            },
                            {
                                name: "供暖系统",
                                smooth: true,
                                type: "line",
                                data: response.data.systemPowercostStd
                            }
                        ],
                        color: ["#b9d0ff", "#fddd99"]
                    };
                    chart23 = echarts.init(document.getElementById("chart23"));
                    chart23.setOption(option);
                }else{
                    alert(response.message)
                }
            });
        },
        initChart31: function () {
            if (chart31) {
                chart31.dispose();
            }
            var type = $("#timeType31 li.active").attr("type");
            var timeLength = 0;
            if(type==0){
                timeLength=7;
            }else if(type==1){
                timeLength=30
            }else if(type==2){
                timeLength=30
            }
            global.get("/web/analysis/pipe_network/cold_hot_pump_transmission_coefficient/"+project.id+"?timeMode="+type+"&timeLength="+timeLength,response=>{
                if(response.success){
                    var xArr = []
                    var dates = response.data.dates;
                    var yArr = response.data.pumpTransmissionCoefficient;
                    for(var i=0;i<yArr.length;i++){
                        yArr[i] = yArr[i].toFixed(3)
                    }
                    for(var i=0;i<dates.length;i++){
                        if(type==0){
                            xArr.push(dates[i].substring(11,13)+"时");
                        }else if(type==1){
                            xArr.push(dates[i].substring(8,10)+"日");
                        }else if(type==2){
                            xArr.push(dates[i].substring(5,7)+"月");
                        }
                    }
                    var option = {
                        tooltip: {
                            trigger: "axis"
                        },
                        grid: {
                            left: 24,
                            right: 24,
                            bottom: 0,
                            top: 36,
                            containLabel: true
                        },
                        xAxis: [
                            {
                                type: "category",
                                boundaryGap: false,
                                axisTick: {
                                    show: false
                                },
                                axisLine: {
                                    lineStyle: {
                                        color: "#ffffff"
                                    }
                                },
                                axisLabel: {
                                    color: "#94d3ff"
                                },
                                data: xArr
                            }
                        ],
                        yAxis: [
                            {
                                name: "%",
                                type: "value",
                                splitNumber: 2,
                                max: 100,
                                nameTextStyle: {
                                    color: "#94d3ff",
                                    padding: [0, 36, 6, 0]
                                },
                                axisTick: {
                                    show: false
                                },
                                axisLine: {
                                    show: false
                                },
                                axisLabel: {
                                    color: "#94d3ff",
                                    formatter: '{value}'
                                },
                                splitLine: {
                                    lineStyle: {
                                        type: "dashed",
                                        color: "#94d3ff",
                                        opacity: 0.5
                                    }
                                }
                            }
                        ],
                        series: [
                            {
                                name: "冷热水泵输送系数",
                                smooth: true,
                                type: "line",
                                data: yArr
                            },
                        ],
                        color: ["#b9d0ff", "#fddd99"]
                    };
                    chart31 = echarts.init(document.getElementById("chart31"));
                    chart31.setOption(option);
                }else{
                    alert(response.message)
                }
            });
        },
        initChart32: function () {
            if (chart32) {
                chart32.dispose();
            }
            var type = $("#timeType32 li.active").attr("type");
            var timeLength = 0;
            if(type==0){
                timeLength=7;
            }else if(type==1){
                timeLength=30
            }else if(type==2){
                timeLength=30
            }
            global.get("/web/analysis/pipe_network/ground_source_pump_transmission_coefficient/"+project.id+"?timeMode="+type+"&timeLength="+timeLength,response=>{
                if(response.success){
                    var xArr = []
                    var dates = response.data.dates;
                    var yArr = response.data.pumpTransmissionCoefficient;
                    for(var i=0;i<yArr.length;i++){
                        yArr[i] = yArr[i].toFixed(3)*100
                    }
                    for(var i=0;i<dates.length;i++){
                        if(type==0){
                            xArr.push(dates[i].substring(11,13)+"时");
                        }else if(type==1){
                            xArr.push(dates[i].substring(8,10)+"日");
                        }else if(type==2){
                            xArr.push(dates[i].substring(5,7)+"月");
                        }
                    }
                    var option = {
                        tooltip: {
                            trigger: "axis"
                        },
                        grid: {
                            left: 24,
                            right: 24,
                            bottom: 0,
                            top: 36,
                            containLabel: true
                        },
                        xAxis: [
                            {
                                type: "category",
                                boundaryGap: false,
                                axisTick: {
                                    show: false
                                },
                                axisLine: {
                                    lineStyle: {
                                        color: "#ffffff"
                                    }
                                },
                                axisLabel: {
                                    color: "#94d3ff"
                                },
                                data: xArr
                            }
                        ],
                        yAxis: [
                            {
                                name: "%",
                                type: "value",
                                splitNumber: 2,
                                max: 100,
                                nameTextStyle: {
                                    color: "#94d3ff",
                                    padding: [0, 36, 6, 0]
                                },
                                axisTick: {
                                    show: false
                                },
                                axisLine: {
                                    show: false
                                },
                                axisLabel: {
                                    color: "#94d3ff",
                                    formatter: '{value}'
                                },
                                splitLine: {
                                    lineStyle: {
                                        type: "dashed",
                                        color: "#94d3ff",
                                        opacity: 0.5
                                    }
                                }
                            }
                        ],
                        series: [
                            {
                                name: "冷热水泵输送系数",
                                smooth: true,
                                type: "line",
                                data: yArr
                            },
                        ],
                        color: ["#b9d0ff", "#fddd99"]
                    };
                    chart32 = echarts.init(document.getElementById("chart32"));
                    chart32.setOption(option);
                }else{
                    alert(response.message)
                }
            });
        },
        initChart41: function () {
            if (chart41) {
                chart41.dispose();
            }
            var type = $("#timeType41 li.active").attr("type");
            var timeLength = 0;
            var baseYear = "";
            if(type==1){
                timeLength=10;
            }else if(type==2){
                timeLength=10
            }else if(type==3){
                timeLength=10
                baseYear = "&baseYear="+new Date().getFullYear()
            }
            global.get("/web/analysis/heat_balance/totalEnergy/"+project.id+"?timeMode="+type+"&timeLength="+timeLength+"&mode=1"+baseYear,response=>{
                if(response.success){
                    var xArr = []
                    var dates = response.data.dates;
                    var yArr = response.data.totalEnergy;
                    for(var i=0;i<dates.length;i++){
                        if(type==1){
                            xArr.push(dates[i].substring(8,10)+"日");
                        }else if(type==2){
                            xArr.push(dates[i].substring(5,7)+"月");
                        }else if(type==3){
                            xArr.push(dates[i].substring(0,4)+"年");
                        }
                    }
                    var option = {
                        tooltip: {
                            trigger: "axis"
                        },
                        legend: {
                            data: ["累计热量"],
                            right: 24,
                            top: 0,
                            selectedMode: false,
                            textStyle: {
                                color: "#94d3ff"
                            }
                        },
                        grid: {
                            left: 24,
                            right: 24,
                            bottom: 0,
                            top: 36,
                            containLabel: true
                        },
                        xAxis: [
                            {
                                type: "category",
                                boundaryGap: false,
                                axisTick: {
                                    show: false
                                },
                                axisLine: {
                                    lineStyle: {
                                        color: "#ffffff"
                                    }
                                },
                                axisLabel: {
                                    color: "#94d3ff"
                                },
                                data: xArr
                            }
                        ],
                        yAxis: [
                            {
                                name: "MWH",
                                type: "value",
                                splitNumber: 2,
                                nameTextStyle: {
                                    color: "#94d3ff"
                                },
                                axisTick: {
                                    show: false
                                },
                                axisLine: {
                                    show: false
                                },
                                axisLabel: {
                                    color: "#94d3ff"
                                },
                                splitLine: {
                                    lineStyle: {
                                        type: "dashed",
                                        color: "#94d3ff",
                                        opacity: 0.5
                                    }
                                }
                            }
                        ],
                        series: [{
                            name:"累计热量",
                            smooth: true,
                            type: "line",
                            data:yArr
                        }],
                        color: ["#b9d0ff", "#fddd99"]
                    };
                    chart41 = echarts.init(document.getElementById("chart41"));
                    chart41.setOption(option);
                }else{
                    alert(response.message)
                }
            });
        },
        initChart42: function () {
            if (chart42) {
                chart42.dispose();
            }
            var type = $("#timeType42 li.active").attr("type");
            var timeLength = 0;
            var baseYear = "";
            if(type==1){
                timeLength=10;
            }else if(type==2){
                timeLength=10
            }else if(type==3){
                timeLength=10
                baseYear = "&baseYear="+new Date().getFullYear()
            }
            global.get("/web/analysis/heat_balance/totalEnergy/"+project.id+"?timeMode="+type+"&timeLength="+timeLength+"&mode=0"+baseYear,response=>{
                if(response.success){
                    var xArr = []
                    var dates = response.data.dates;
                    var yArr = response.data.totalEnergy;
                    for(var i=0;i<dates.length;i++){
                        if(type==1){
                            xArr.push(dates[i].substring(8,10)+"日");
                        }else if(type==2){
                            xArr.push(dates[i].substring(5,7)+"月");
                        }else if(type==3){
                            xArr.push(dates[i].substring(0,4)+"年");
                        }
                    }
                    var option = {
                        tooltip: {
                            trigger: "axis"
                        },
                        legend: {
                            data: ["累计冷量"],
                            right: 24,
                            top: 0,
                            selectedMode: false,
                            textStyle: {
                                color: "#94d3ff"
                            }
                        },
                        grid: {
                            left: 24,
                            right: 24,
                            bottom: 0,
                            top: 36,
                            containLabel: true
                        },
                        xAxis: [
                            {
                                type: "category",
                                boundaryGap: false,
                                axisTick: {
                                    show: false
                                },
                                axisLine: {
                                    lineStyle: {
                                        color: "#ffffff"
                                    }
                                },
                                axisLabel: {
                                    color: "#94d3ff"
                                },
                                data: xArr
                            }
                        ],
                        yAxis: [
                            {
                                name: "MWH",
                                type: "value",
                                splitNumber: 2,
                                nameTextStyle: {
                                    color: "#94d3ff"
                                },
                                axisTick: {
                                    show: false
                                },
                                axisLine: {
                                    show: false
                                },
                                axisLabel: {
                                    color: "#94d3ff"
                                },
                                splitLine: {
                                    lineStyle: {
                                        type: "dashed",
                                        color: "#94d3ff",
                                        opacity: 0.5
                                    }
                                }
                            }
                        ],
                        series: [{
                            name:"累计冷量",
                            smooth: true,
                            type: "line",
                            data:yArr
                        }],
                        color: ["#b9d0ff", "#fddd99"]
                    };
                    chart42 = echarts.init(document.getElementById("chart42"));
                    chart42.setOption(option);
                }else{
                    alert(response.message)
                }
            });
        },
        initSelect: function () {
            var start = 2019;
            var end = parseInt(new Date().getFullYear());
            var dataDemo0 = [];
            baseYear1 = end;
            baseYear2 = end;
            baseYear3 = end;
            for(var i=end;i>=start;i--){
                var item = {};
                item.id = i;
                item.text = i;
                dataDemo0.push(item)
            }
            $("#timeType21").select2({
                minimumResultsForSearch:-1,
                width: 120,
                data: dataDemo0
            })
            $("#timeType22").select2({
                minimumResultsForSearch:-1,
                width: 120,
                data: dataDemo0
            })
            $("#timeType23").select2({
                minimumResultsForSearch:-1,
                width: 120,
                data: dataDemo0
            })
        },
        /** 事件绑定 */
        eventBind: function () {
            $(document).on("click", ".tab-nav li", function () {
                $(this).addClass("active").siblings("li").removeClass("active");
                var index = $(this).attr("type");
                $(".tab-wrapper").eq(index-1).removeClass("hidden").siblings(".tab-wrapper").addClass("hidden");
                if(index==1) {
                    app.initTab1()
                } else if(index==2) {
                    app.initTab2()
                } else if(index==3) {
                    app.initTab3()
                } 
            })
            $(document).on("click", ".table-tab li", function () {
                $(this).addClass("active").siblings("li").removeClass("active");
                var index = $(this).index();
                $('.tab-table-wrap').eq(index).removeClass('hidden').siblings('.tab-table-wrap').addClass('hidden');
            })
            
            window.onresize = function () {
                // getTime.resize();
            };
            $(document).on("click", "#timeType11 li:not('.active')", function () {
                $(this).addClass("active").siblings("li").removeClass("active");
                app.initChart11();
            });
            $(document).on("click", "#timeType12 li:not('.active')", function () {
                $(this).addClass("active").siblings("li").removeClass("active");
                app.initChart12();
            });
            $(document).on("click", "#timeType14 li:not('.active')", function () {
                $(this).addClass("active").siblings("li").removeClass("active");
                app.initChart14();
            });
            $(document).on("click", "#timeType31 li:not('.active')", function () {
                $(this).addClass("active").siblings("li").removeClass("active");
                app.initChart31();
            });
            $(document).on("click", "#timeType32 li:not('.active')", function () {
                $(this).addClass("active").siblings("li").removeClass("active");
                app.initChart32();
            });
            $(document).on("click", "#timeType41 li:not('.active')", function () {
                $(this).addClass("active").siblings("li").removeClass("active");
                app.initChart41();
            });
            $(document).on("click", "#timeType42 li:not('.active')", function () {
                $(this).addClass("active").siblings("li").removeClass("active");
                app.initChart42();
            });
            
        }
        
    };
    return app;
});